#include "stdafx.h"
#include "MyLine.h"
#include <Windows.h>
#include "Winuser.h"

MyLine::MyLine()
{
	m_begin = 0;
	m_end = 0;
	m_color = RGB(0, 0, 0);
}

MyLine::MyLine(const MyLine& line)
{
	this->m_begin = line.m_begin;
	this->m_end = line.m_end;
	this->m_color = line.m_color;
}

MyLine::MyLine(CPoint begin, CPoint end, COLORREF color = RGB(0, 0, 0))
{
	m_begin = begin;
	m_end = end;
	m_color = color;
}

MyLine::MyLine(int xBegin, int yBegin, int xEnd, int yEnd, COLORREF color = RGB(0, 0, 0))
{
	m_begin.x = xBegin;
	m_begin.y = yBegin;
	m_end.x = xEnd;
	m_end.y = yEnd;
	m_color = color;
}

void MyLine::setColor(COLORREF color)
{
	this->m_color = color;
}

void MyLine::setColor(BYTE r, BYTE g, BYTE b)
{
	this->m_color = RGB(r, g, b);
}

void MyLine::Draw()
{
	HPEN hPen = ::CreatePen(PS_SOLID, 1, m_color);	
	HDC hdc = ::GetDC(NULL);

	::SelectObject(hdc, hPen);

	::MoveToEx(hdc, m_begin.x, m_begin.y, NULL);
	::LineTo(hdc, m_end.x, m_end.y);
	::ReleaseDC(NULL, hdc);
}